package de.uni_stuttgart.ipvs.ids.summationImpl;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;

import de.uni_stuttgart.ipvs.ids.summation.ISummationSession;

public class SummationSession extends UnicastRemoteObject implements ISummationSession {

	private static final long serialVersionUID = -3473539673278515008L;
	
	/**
	 * Store the current sum
	 */
	int sum;
	
	/**
	 * Create a new session with an initial sum of 0.
	 * @throws RemoteException
	 */
	public SummationSession() throws RemoteException {
		sum = 0;
	}
	
	/**
	 * Add the given value to the current sum.
	 */
	public void add(int value) throws RemoteException {
		sum += value;
	}
	
	/**
	 * Return the current sum.
	 */
	public int getSum() throws RemoteException {
		return sum;
	}
}
